<title>Change password</title>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="common.Privilege"%>
<%@page import="model.bean.Account"%>
<jsp:include page="common/header.jsp"></jsp:include>
<style type="text/css">
.form-control {
	width: 70%;
	margin-left: 150px;
}
</style>
<script type="text/javascript">
	function checkValid() {
		var newpass = fr_update.elements["password"].value;
		var rnewpass = fr_update.elements["rpassword"].value;
		if (newpass != rnewpass) {
			document.getElementById('err').innerHTML = "Mật khẩu nhập lại không đúng";
			return false;
		}
		return true;
	}
</script>
<div id="page-wrapper">
	<%
		// Check Login privilege
		Account account = (Account) session.getAttribute("account");
		if(account == null){
	    	response.sendRedirect("${pageContext.request.contextPath}/CheckPrivilegeServlet");
		}else{
		    if(account.getPrivilege() != Privilege.MANAGE_SERVICE){%>
		    	<jsp:include page="error.jsp"></jsp:include>
			<%} else {%>
	
	<form name="fr_update" method="post"
		action="${pageContext.request.contextPath}/AccountSettingServlet?action=changePassword"
		onsubmit="return checkValid();">
		<div class="panel panel-default" style="width: 60%; margin: 0 auto;">
			<div class="panel-heading">Thay đổi mật khẩu</div>
			<div class="panel-body">
				<div class="form-group">
					<center>
						<label id="err" style="color: red;"> ${errMessage} </label>
					</center>
				</div>
				<div class="form-group">
					<label>Mật khẩu cũ: </label> <input name="oldpassword"
						id="oldpassword" class="form-control" type="password"
						required="required">
				</div>
				<div class="form-group">
					<label>Mật khẩu mới: </label> <input name="password" id="password"
						class="form-control" type="password" required="required">
				</div>
				<div class="form-group">
					<label>Nhập lại Mật khẩu mới: </label> <input name="rpassword"
						id="rpassword" class="form-control" type="password"
						required="required">
				</div>
				<div style="float: right; margin-right: 100px;">
					<button type="submit" class="btn btn-success btn-sm">Cập
						nhập</button>
					<button type="reset" class="btn btn-success btn-sm">Xóa</button>
				</div>
			</div>
		</div>
	</form>
</div>
<!-- /. PAGE WRAPPER  -->
<jsp:include page="common/footer.jsp"></jsp:include>
<% } 
}%>